import {addType,delType,getType,changeType} from "../../api/classType"

const state = {
    classtype:[]
}

const mutations ={
    // 添加的方法
    ADD_TYPE(state,payload){
        state.classtype.push(payload)
    },
    // 设置的方法
    SET_TYPE1(state,payload){
        state.classtype =payload
    },

}


const actions ={
    async addType({commit},typeInfo){
        let res = await  addType(typeInfo);
        // console.log(res,"res")
        // {}  [{},{},{},{}]
        // 添加后返回都西昂
        commit("ADD_TYPE",res.data)
        // console.log(res.data)
    },
    async getType({commit}){
        let res = await  getType();
        commit("SET_TYPE1",res.data)
        // console.log(res,"res")
    },
    async delType({commit},id){
      
        await delType(id)
      
        return {
            code:200,
            msg:"删除成功"
        }
    }
}

export default {
    state,
    mutations,
    actions
}